package javaClassExercise.fanshe;

/**
 * Created by lomo.
 */
public class TestReflect {
    public static void main(String... arg) throws Exception{
//        TestReflect testReflect = new TestReflect();
//        System.out.println(testReflect.getClass()); // class javaClassExercise.fanshe.TestReflect
//        System.out.println(TestReflect.class);  // class javaClassExercise.fanshe.TestReflect
//        System.out.println(testReflect.getClass().getName()); // javaClassExercise.fanshe.TestReflect (包名+类名)
//
//        System.out.println(testReflect.getClass().getSimpleName());  //  TestReflect, 直接获取类名
//        System.out.println(testReflect.getClass().getPackage());  // package javaClassExercise.fanshe, 直接获取包名
//
//
//        System.out.println(testReflect.getClass().getSuperclass()); // class java.lang.Object
//        System.out.println(testReflect.getClass().getClass()); // class java.lang.Class

        Solution solution = new Solution();

        //Class.forName(), 返回 一个类，作用：要求JVM查找并加载指定的类
        Solution solution1 = (Solution)Class.forName("javaClassExercise.fanshe.Solution").newInstance();
        solution1.printSolution2();

        Class c = Class.forName("javaClassExercise.fanshe.Solution");
        Solution solution2 = (Solution)c.newInstance();
        solution2.printSolution();

        //System.out.println(soluton.getClass());//class javaClassExercise.fanshe.Soluton
        //System.out.println(soluton.getClass().getDeclaredClasses()); //[Ljava.lang.Class;@4203fcfb

        //soluton.printSolution();
    }
}

class Solution{
    private String name;
    private int age;

    private float height;

    public Solution() {

    }

    public Solution(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public Solution(float h) {
        this.height = h;
    }

    public void printSolution() {
        System.out.println("This is Class's Solution Method");
    }

    public void printSolution2() {
        System.out.println("This is Class's printSolution2 Method");
    }

}
